package models;

import play.data.validation.Required;
import play.db.jpa.Model;

import javax.persistence.*;

@Entity
public class Participation extends Model{
	
	@Required
	@ManyToOne
	public Agent agent;
	
	@Required
	@ManyToOne
	public FMPA fmpa;
	
	@Required
	@ManyToOne
	public RoleFMPA role;
	
	public String observation;
	
	public boolean valide;

	public Participation(Agent agent, FMPA fmpa, RoleFMPA role) {
		this.agent = agent;
		this.fmpa = fmpa;
		this.role = role;
	}
	
	public void valider(){
		valide=true;
	}
	
	public void refuser(){
		valide=false;
	}
	
	public boolean equals(Participation p){
		return p.agent.equals(this.agent)&&p.fmpa.equals(this.fmpa)&&p.role.equals(this.role);

	}
}
